package lex.profile.ui.outline;

import javax.swing.event.TreeModelListener;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;

import com.vladium.utils.IObjectProfileNode;

public class ProfileTreeModel implements TreeModel
{
	private IObjectProfileNode root = null;
	
	public ProfileTreeModel( IObjectProfileNode root )
	{
		this.root = root;
	}
	
	@Override
	public Object getChild( Object parent, int index )
	{
		return ((IObjectProfileNode)parent).children()[index];
	}

	@Override
	public int getChildCount( Object parent )
	{
		return ((IObjectProfileNode)parent).children().length;
	}

	@Override
	public int getIndexOfChild( Object parent, Object child )
	{
		return org.lex.utils.Arrays.firstReference( ((IObjectProfileNode) parent).children(), child );
	}

	@Override
	public Object getRoot()
	{
		return root;
	}

	@Override
	public boolean isLeaf( Object node )
	{
		return 0 == ((IObjectProfileNode)node).children().length;
	}
	
	//current not using
	@Override
	public void addTreeModelListener( TreeModelListener l )
	{
	}


	@Override
	public void removeTreeModelListener( TreeModelListener l )
	{
	}

	@Override
	public void valueForPathChanged( TreePath path, Object newValue )
	{
	}
}
